package com.maozzi.common.model;

import com.maozzi.common.constant.ErrorCodeConstant;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 返回值基类
 *
 * @author maozi
 */
@Data
@NoArgsConstructor
public class ResultVO<T> {
    private String code;
    private String message;
    private T data;

    private ResultVO(String code, String message) {
        this(code, message, null);
    }

    private ResultVO(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static ResultVO<String> success() {
        return new ResultVO<>(ErrorCodeConstant.OK, "成功");
    }

    public static ResultVO<String> fail() {
        return new ResultVO<>(ErrorCodeConstant.FILED, "服务器走神了");
    }

}
